package com.dartsstats.DM;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class GameDM extends SQLiteOpenHelper {

	public static final String TABLE_GAME = "Game";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_MATCH = "match";
	public static final String COLUMN_GAME_NUMBER = "gameNumber";
	public static final String COLUMN_HOME_SCORE = "homeScore";
	public static final String COLUMN_AWAY_SCORE = "awayScore";
	
	private static final String DATABASE_NAME = "Game.db";
	private static final int DATABASE_VERSION = 1;
	
	private static final String DATABASE_CREATE = "create table "
			+ TABLE_GAME + "(" + COLUMN_ID
			+ " integer primary key autoincrement, " + COLUMN_MATCH
			+ " integer not null, " + COLUMN_GAME_NUMBER
			+ " integer not null, " + COLUMN_HOME_SCORE
			+ " integer not null, " + COLUMN_AWAY_SCORE
			+ " integer not null);";

	public GameDM(Context context){
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		database.execSQL(DATABASE_CREATE);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(TeamDM.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
				+ newVersion + ", which will destory all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_GAME);
		onCreate(db);

	}

}
